package com.jiuwan.gamepass.controller;

import com.jiuwan.gamepass.dto.authDto.Result;
import com.jiuwan.gamepass.dto.authDto.ResultCode;
import com.jiuwan.gamepass.pojo.authPojo.SysApi;
import com.jiuwan.gamepass.service.userImpl.SysApiServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0
 * 功能目的描述 ：用于 管理用户的相关权限         ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-06-29 10:21
 */

@Controller
@RequestMapping("/api")
public class ApiController {

    @Autowired
    private SysApiServiceImpl sysApiService;

    @RequestMapping("/selectById")
    @ResponseBody
    public Result selectById(int id){
        Result result = sysApiService.selectById(id);
        return result;
    }


    @RequestMapping("/selectPage")
    @ResponseBody
    public Result selectPage(int id,int current,int size){
        Result result = sysApiService.selectPage(id,current,size);
        return result;
    }



    @RequestMapping("/addApi")
    @ResponseBody
    public Result addApi(@RequestBody SysApi sysApi){
        if (sysApi == null) {
            Result error = Result.error(ResultCode.PARAM_NOT_BLANK);
            return error;
        }
        Result result = sysApiService.addApi(sysApi);
        return result;
    }

    @RequestMapping("/deleteByIdAndUrl")
    @ResponseBody
    public Result deleteByIdAndUrl(String id,String url){
        Result result = sysApiService.deleteByIdAndUrl(id, url);
        return result;
    }







}
